import { FeedbackParams, LevelOption } from '@/models/feedback'
import { APPConfig, FeedbackType } from '@/models/sys'
import { http } from '@/utils/http'
import { IOssModel } from '@/utils/upload/browserUpload'

/**
 * 阿里云oss鉴权
 * @param type - 类型 目前就avatar(头像)  suggestion（意见反馈） consult（聊天） 后续逐渐新增
 * @returns
 */
export const checkOss = (type: 'avatar' | 'suggestion' | 'consult') =>
  http.get('/api/ali-yun/check-oss', { type })

export const getSts = () => http.post<IOssModel>('/library-client/api/wxwork/common/get-sts-token')

/** 错误反馈的选项 */
export const getFeedbackOptions = (params: { type: FeedbackType }) =>
  http.get<LevelOption[]>('/library-client/api/wxwork/common/feedback-options', params)

/** 提交错误反馈 */
export const submitFeedback = (params: FeedbackParams) =>
  http.post('/library-client/api/wxwork/common/feedback', params)

/** 全局配置 */
export const getConfig = () => http.get<APPConfig>('/library-client/api/wxwork/common/config')
